package com.yonyou.cyxdms.sysAuth.service.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.dao.base.SuperMapper;
import com.yonyou.cyxdms.sysAuth.service.dto.EmployeeDTO;
import com.yonyou.cyxdms.sysAuth.service.entity.EmpPo;
import com.yonyou.cyxdms.sysAuth.service.vo.authorization.AuthorizationVO;
import com.yonyou.cyxdms.sysAuth.service.vo.user.RoleUserVo;
import com.yonyou.cyxdms.sysmanage.client.vo.user.UserInfoVO;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author quankk
 * @since 2019-02-28
 */
public interface EmpMapper extends SuperMapper<EmpPo> {

    EmployeeDTO selectByEmployeeNo(@Param("appId") String appId, @Param("employeeNo") String employeeNo);

    Long getEmployeeIdByUserCode(@Param("userCode") String userCode, @Param("appId") String appId);

    Long getEmpIdByUserCode(@Param("userCode") String userCode, @Param("appId") String appId);

    /**
     * @author ：quankk
     * @date ：2019/7/18 17:01
     * @description：加载授权主界面
     */
    List<AuthorizationVO> queryAuthorization(Page<AuthorizationVO> page, @Param("param") Map<String, String> param);

    List<String> selectPositionName(@Param("userId") Integer userId);

    /**
     * @author ：quankk
     * @date ：2019/7/18 18:23
     * @description：
     */
    List<Map> getRoleById(@Param("id") Integer id);

    /**
     * @author ：quankk
     * @date ：2019/7/19 10:03
     * @description：
     */
    List<Map> hasUser(@Param("employeeId") Integer employeeId, @Param("type") Integer type);

    /**
     * @author：chenzb
     * @since：2019-07-23
     */
    int insertByKey(EmpPo empPo);

    List<AuthorizationVO> queryAuthorization2(Page<AuthorizationVO> page2, @Param("param") Map<String, String> param2);

    /**
     * @param userIds      需要查询的id
     * @param isContain    true,正向查询ids,false反向查询
     * @auther: tanjie
     * @since: 2019/9/23
     */
    List<Map<String, Object>> queryUserInfoByIDS(@Param("ids") List<String> userIds,
                                                 @Param("isContain") Boolean isContain,
                                                 @Param("appId") String appId,
                                                 @Param("ownerCode") String ownerCode);
/**根据手机号获取顾问组织信息
 * @param:
 * @return:
 * @auther: tanjie
 * @since: 2019/10/21
 */
    RoleUserVo getOrgInfoByPhone(@Param("info") RoleUserVo roleUserVo,
                                 @Param("code")Integer code);

    List<UserInfoVO> queryUserByOrgId(@Param("orgId") Long orgId, @Param("positionCodes") List<Integer> positionCodes, @Param("companyId") Long companyId, @Param("userPhone") String userPhone);


    List<UserInfoVO> queryUserByOrgIds(@Param("orgIds") String[] orgIds, @Param("positionCodes") List<Integer> positionCodes, @Param("companyId") Long companyId, @Param("userPhone") String userPhone);
    List<UserInfoVO> queryUserByOrgIdsSp(@Param("orgIds") String[] orgIds, @Param("positionCodes") List<Integer> positionCodes, @Param("companyId") Long companyId, @Param("userPhone") String userPhone);

    List<UserInfoVO> queryUserByOwnerCode(@Param("ownerCode") String ownerCode, @Param("companyId") Long companyId, @Param("userPhone") String userPhone, @Param("positionCodes") List<Integer> positionCodes);
    List<UserInfoVO> queryUserByOwnerCodeFp(@Param("ownerCode") String ownerCode, @Param("companyId") Long companyId, @Param("userPhone") String userPhone, @Param("positionCodes") List<Integer> positionCodes);

    Integer findCountByPhoneAndAppId(@Param("phone") String phone, @Param("appId") String appId);

    EmpPo queryEmpByCode(@Param("username") String username, @Param("appId") String appId);

    void updatePhoneByPhone(@Param("phone") String phone, @Param("appId") String appId);

    Integer findCountByPhoneAndAppIdAndEmpId(@Param("phone") String phone, @Param("appId") String appId, @Param("empId") Long empId);

    String findEmployeeNoByOpenIdAndAppId(@Param("openId") String openId, @Param("appId") String appId);

    void updateOpenId(@Param("openId") String openId, @Param("appId") String appId);

    String findWechatByOpenIdAndAppId(@Param("openId") String openId, @Param("appId") String appId);

    void updatePhoneToNull(@Param("phone") String phone, @Param("appId") String appId);

    String getHeadPortrait(@Param("empId") Long empId);

    Integer selectOnJobCountByPhone(@Param("mobilePhone") String mobilePhone, @Param("appId") String appId, @Param("empId") Long empId);

    RoleUserVo getOrgInfoByPhoneAndOwnerCode(@Param("info") RoleUserVo roleUserVo,
                                             @Param("code")Integer code);

    RoleUserVo consultantVerification(@Param("info") RoleUserVo roleUserVo,
                                             @Param("code")Integer code);

    List<UserInfoVO> queryUserByPositionCodes(@Param("positionCodes") List<Integer> positionCodes, @Param("companyId") Long companyId, @Param("userPhone") String userPhone);
    List<UserInfoVO> queryUserByPositionCodesZy(@Param("positionCodes") List<Integer> positionCodes, @Param("companyId") Long companyId, @Param("userPhone") String userPhone);
}
